<?php

use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::middleware('auth:api')->get('/user', function (Request $request) {

    return $request->user();
});
Route::group(['namespace'=>'Api'],function(){
    //后端应用
    Route::get('/getGoodsPlan','AdminOrderController@getGoodsPlan'); // 套餐列表
    Route::get('/getGoodsPlanid','AdminOrderController@getGoodsPlanid'); // 套餐列表
    Route::any('/cookies','AdminOrderController@get_cookies'); // 套餐列表

    Route::any('/send_message','WeChatLoginController@send_message'); // 套餐列表
    Route::any('/send','WeChatLoginController@send'); // 套餐列表

    Route::any('/login_wx', 'WeChatLoginController@login_wx')->middleware('api.log'); //正式微信授权登录
    Route::any('/getUser', 'WeChatLoginController@getUser')->name('getUser'); //
    Route::any('/wx_login', 'WeChatLoginController@wx_login')->middleware('api.log'); //login 这个域名直接

    // 微信异步通知route
    Route::any('/notify_wx', 'NotifyController@notify_wx')->name('notify_wx');

    Route::any('/test', 'MoveController@test');
});

Route::group(['namespace'=>'Api','middleware'=>['api.log','api.login']],function(){
    //图片上传
    Route::group(['prefix'=>'oss'],function($router){
        $router->any('/upload','UploadController@upload'); //用户提现列表
    });
    //用户功能
    Route::group(['prefix'=>'users'],function($router){
        $router->post('/users_cash','UserController@users_cash'); //用户提现列表
        $router->post('/users_cash_edit','UserController@users_cash_edit'); //用户提现列表
        $router->post('/users_cash_save','UserController@users_cash_save'); //用户提现列表

        $router->post('/users_relation','UserController@users_relation'); //用户关系设置
        $router->post('/users_info','UserController@users_info'); //用户关系设置
        $router->post('/users_auth','UserController@users_auth'); //实名认证页面
        $router->post('/users_auth_save','UserController@users_auth_save'); //实名认证保存
    });
    //商品管理
    Route::group(['prefix'=>'goods'],function($router){
        $router->post('/goods_list','ShopGoodController@goods_list'); //商品列表
        $router->post('/goods_return','ShopGoodController@goods_return'); // 返佣商品列表
        $router->post('/get_order_info','ShopGoodController@get_order_info'); // 创建订单时获取的信息
        $router->post('/details','ShopGoodController@goods_detail'); // 返佣商品列表
        $router->post('/create_order','OrderController@create_order'); // 返佣商品列表
    });

    //明细
    Route::group(['prefix'=>'detail'],function($router){
        $router->any('/earn_list','DetailController@earn_list'); //收益明细
        $router->any('/order_list','DetailController@order_list'); //订单记录
        $router->any('/recommend_list','DetailController@recommend_list'); //推广记录
    });


    Route::middleware('auth:api')->group(function () {

        Route::get('/test', 'MoveController@test');
//        Route::post('/extension_link','CommissionController@extension_link'); // 返佣商品列表

    });
    Route::any('/get_qrcode','CommissionController@get_qrcode'); // 获取推广二维码
    Route::any('/ceshi','CommissionController@ceshi'); // 获取推广二维码
    Route::post('/extension_link','CommissionController@extension_link')->name('extension_link_short'); // 返佣商品列表
    Route::post('/get_all_link','CommissionController@get_all_link')->name('get_all_link'); // 返佣商品列表
    Route::post('/phone','PhoneNumberController@phone_number'); // 获取手机号
    Route::post('/phone_meal','PhoneNumberController@phone_meal'); // 获取手机号
    Route::post('/member_card','PhoneNumberController@member_card'); // 获取手机号
    Route::post('/create_order','OrderController@create_order'); // 创建订单
    Route::post('/card_discern','OrderController@card_discern'); // 实名认证
    Route::post('/make_phone_order','OrderController@make_phone_order'); // 实名认证
    Route::post('/query','OrderController@order_query'); // 查询订单
    Route::post('/sync','OrderController@sync_orders'); // 查询订单
    Route::post('/phone_ownership','PhoneNumberController@phone_ownership'); // 手机号归属地
    Route::any('/login', 'AuthenticateController@auto_login')->name('login');
    Route::any('/move', 'MoveController@index')->name('move');
    Route::any('/get_agreement', 'OrderController@get_agreement')->name('get_agreement');


});